/**
 * 
 */
package com.effectivsocial.service.impl;

import java.util.Locale;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.scheduling.annotation.Async;

import jodd.mail.Email;



import com.effectivsocial.email.EmailBodyPreparer;
import com.effectivsocial.email.EmailOperationTemplate;
import com.effectivsocial.domain.User;
import com.effectivsocial.service.api.EmailService;

/**
 * @author Dhrubo
 *
 */
@Named
public class EmailServiceImpl implements EmailService{
 
	@Inject
	private EmailOperationTemplate emailOperationTemplate;

	@Override
	@Async
	public void sendOnRegister(User user, Locale locale) {
		EmailBodyPreparer<User> emailBodyPreparer = new EmailBodyPreparer<User>(user,"registration-email",locale);
        Email email = Email.create()
        			.to(user.getEmail())
        			.from("info@gooruda.com")
        			.subject("Gooruda - Please activiate your account");
        
        emailOperationTemplate.send(email, emailBodyPreparer);
		
	}
}
